package stu.sup.controller.orders;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import stu.sup.entity.AddressInfo;
import stu.sup.entity.UserLogin;
import stu.sup.service.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class OrderController {
    @Autowired
    private IUserLoginService userLoginService;
    @Autowired
    private IOderService oderService;
    @Autowired
    private IBuycarService buycarService;
    @Autowired
    private IUserInfoService userInfoService;
    @Autowired
    private IAddressInfoService addressInfoService;
    @RequestMapping("order")
    public String gotobuycar(Model model, HttpServletRequest request){
        Object name=request.getSession().getAttribute("loginUserName");
        UserLogin userLogin=userLoginService.selectbyUsername(name.toString());
        List<AddressInfo> addressInfos=addressInfoService.find(userLogin.getId());
        model.addAttribute("addressInfo",addressInfos);

        //boolean flag=oderService.saveorder(userLogin.getId(),buycarId)
        return "view/account";
    }
}
